<?php
if(command("lag")){
  $pingTime=microtime(true);
  $pingChannel=$bufferA[2];
  $checkLag=true;
  SendCommand("PING :Checking lag");
}

if(($bufferA[0]=="PONG") or ($bufferA[1]=="PONG") and stristr($buffer,"Checking lag")){
  if($checkLag){
    $pongTime=microtime(true);
    $lag=$pongTime-$pingTime;
    $realLag=$lag;
    $lag=number_format($lag,3);
    SendCommand("PRIVMSG ".$pingChannel." :Current lag for ".$nickname.": ".$lag." seconds.");
    $checkLag=false;
  }
}
?>